home *** CD-ROM | disk | FTP | other *** search
-
- ; module: vlib
- ; programmer: Ray L. McVay
- ; started: 10 Oct 82
- ; version: 2.01, 3 Aug 84
- ;
- ; A library of c bios video functions originally written to
- ; replace the int10() function of small-c:PC.
-
- ; history:
- ; 1.0 small-c:PC version
- ; 2.0 ported to DeSmet c
-
- ; Calling convention for DeSmet is to push parameters
- ; rightmost first then do an intrasegment call to the
- ; function.
-
- ; Char's, int's and unsigned's are returned in AX.
- ; Long's are returned in DX:AX.
-
- ; CS, DS, SS, SP and BP should be preserved.
-
- CSEG
- VIDEO EQU 16 ;BIOS video interrupt
-
-
- ; get video mode
- ; int get_mode();
-
- PUBLIC GET_MODE_
- GET_MODE_:
- mov ah,15
- int VIDEO
- cbw
- ret
-
-
- ; set video mode
- ; set_mode(mode)
- ; int mode;
-
- PUBLIC SET_MODE_
- SET_MODE_:
- push bp
- mov bp,sp
- mov al,[bp+4]
- mov ah,0
- INT VIDEO
- pop bp
- RET
-
-
- ; set cursor type
- ; set_curtyp(start,end)
- ; int start,end;
- ; Note: if start > end then cursor is turned off.
-
- PUBLIC SET_CURTYP_
- SET_CURTYP_:
- push bp
- mov bp,sp
- mov ch,[bp+4] ; top line
- mov cl,[bp+6] ; bottom line
- mov ah,1
- INT VIDEO
- pop bp
- RET
-
-
- ; gotoxy - set cursor position
- ; gotoxy(x, y, page)
- ; int x,y,page;
-
- PUBLIC GOTOXY_
- GOTOXY_:
- push bp
- mov bp,sp
- mov dl,[bp+4] ; DL = x = column
- mov dh,[bp+6] ; DH = y = row
- mov bh,[bp+8] ; BH = page
- mov ah,2
- INT VIDEO
- pop bp
- RET
-
-
- ; read cursor position
- ; getxy(page)
- ; int page;
- ; xpos = getxy(page) & 255;
- ; ypos = getxy(page) >> 8;
-
- PUBLIC GETXY_
- GETXY_:
- push bp
- mov bp,sp
- mov bh,[bp+4] ;BH = page
- MOV AH,3
- INT VIDEO
- MOV AX,DX ;return(256*row+column)
- pop bp
- RET
-
-
- ; get light pen position
- ; int gltpen(buff)
- ; int buff[4];
- ; Note: Returns 0 if pen was not triggered, 1 if it was.
- ; Stores XY values in integer array at buff.
-
- PUBLIC GLTPEN_
- GLTPEN_:
- push bp
- mov bp,sp
- MOV AH,4
- INT VIDEO
- OR AH,AH ;check status
- JZ DOSTAT ;it was bad
- mov si,[bp+4] ;get addres of buffer
- MOV [SI],BX ;buff[0]=X for graphics
- MOV [SI]+2,CH ;buff[1]=Y
- MOV [SI]+4,DL ;buff[2]=X for text
- MOV [SI]+6,DH ;buff[3]=Y for text
- MOV AH,1 ;return OK status
- DOSTAT:
- MOV AL,AH
- CBW
- pop bp
- RET
-
-
- ; select active page
- ; setpage(page)
- ; int page;
-
- PUBLIC SETPAGE_
- SETPAGE_:
- push bp
- mov bp,sp
- mov al,[bp+4] ;page
- MOV AH,5
- INT VIDEO
- pop bp
- RET
-
-
- ; scroll a window up
- ; scrlup(window,count,attrib)
- ; int window[4],count,attrib;
- ; Note: Window defines the upper-left and lower-right
- ; character positions of an area of the text screen.
- ; A count of 0 clears the window.
- ; The attribute is used on the line(s) blanked.
-
- PUBLIC SCRLUP_
- SCRLUP_:
- push bp
- CALL SCRL1
- MOV AH,6
- INT VIDEO
- pop bp
- RET
-
- SCRL1: mov bp,sp
- mov bx,[bp+6] ;get base of window array
- MOV CL,[bx] ;window[0] = U.L. X
- MOV CH,[bx]+2 ;window[1] = U.L. Y
- MOV DL,[bx]+4 ;window[2] = L.R. X
- MOV DH,[bx]+6 ;window[3] = L.R. Y
- mov al,[bp+8] ;AL = count
- mov bh,[bp+10] ;BH = attribute
- RET
-
-
- ; scroll a window down
- ; scrldn(window,count,attrib)
- ; int window[4],count,attrib;
-
- PUBLIC SCRLDN_
- SCRLDN_:
- push bp
- CALL SCRL1
- MOV AH,7
- INT VIDEO
- pop bp
- RET
-
-
- ; read character & attribute under the cursor
- ; int vgetc(page)
- ; int page;
-
- PUBLIC VGETC_
- VGETC_:
- push bp
- mov bp,sp
- MOV BH,[bp+4]
- MOV AH,8
- INT VIDEO
- pop bp
- RET
-
-
- ; write character & attribute at cursor
- ; vputca(chr,page,count)
- ; int chr,page,count;
- ; Note: Chr contains attribute in hi byte.
- ; Count is the number of times to write the character.
- ; (Good for tops and bottoms of windows or boxes.)
-
- PUBLIC VPUTCA_
- VPUTCA_:
- push bp
- CALL VPUT1
- MOV AH,9
- INT VIDEO
- pop bp
- RET
-
- VPUT1:
- mov bp,sp
- mov AX,[bp+6] ;attrib/char
- mov bh,[bp+8] ;page
- mov CX,[bp+10] ;count
- MOV BL,AH ;attrib to BL
- RET
-
-
- ; vputc - write character only at cursor
- ; vputc(chr,page,count)
- ; int chr,page,count;
- ; Note: Same as vputca() except uses existing attributes.
-
- PUBLIC VPUTC_
- VPUTC_:
- push bp
- CALL VPUT1
- MOV AH,10
- INT VIDEO
- pop bp
- RET
-
-
- ; set background or pallet or alpha border color
- ; pcolor(id,val)
- ; int id,val;
- ; Note: If id == 0 then val is background color.
- ; If id == 1 and mode is graphics then val is pallet.
- ; If id == 1 and mode is text then val is border.
-
- PUBLIC PCOLOR_
- PCOLOR_:
- push bp
- mov bp,sp
- mov bh,[bp+4] ;id
- mov bl,[bp+6] ;val
- MOV AH,11
- INT VIDEO
- pop bp
- RET
-
-
- ; write a graphics dot
- ; plot(color,horz,vert)
- ; int color,horz,vert;
-
- PUBLIC PLOT_
- PLOT_:
- push bp
- CALL SETDOT
- MOV AH,12
- INT VIDEO
- pop bp
- RET
-
- SETDOT:
- mov bp,sp
- mov AX,[bp+6] ;color
- mov CX,[bp+8] ;horiz
- mov DX,[bp+10] ;vert
- RET
-
-
- ; read a graphic dot color
- ; int get_dot(dummy,horz,vert)
- ; int dummy,horz,vert;
- ; Note: the dummy parameter is used so SETDOT can be shared.
-
- PUBLIC GET_DOT_
- GET_DOT_:
- push bp
- CALL SETDOT ; set up the registers
- MOV AH,13
- INT VIDEO
- cbw
- pop bp
- RET ; AX = dot color
-
- END